#include<bits/stdc++.h>
using namespace std;
int main() {
	int y1, y2, m1, m2, d1, d2, i, j, k, l, n = 0;
	scanf("%4d%2d%2d\n%4d%2d%2d", &y1, &m1, &d1, &y2, &m2, &d2);
	int d[100] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	if (y1 != y2) {
		d[2] = 28 + y1 % 4 == 0 && y1 % 100 != 0 || y1 % 400 == 0;
		for (k = d1; k <= d[m1]; k++)
			if (k == y1 / 1000 + y1 / 100 % 10 * 10 && m1 == y1 % 10 * 10 + y1 / 10 % 10)
				n++;
		for (j = m1 + 1; j <= 12; j++) {
			for (k = 1; k <= d[j]; k++)
				if (k == y1 / 1000 + y1 / 100 % 10 * 10 && j == y1 % 10 * 10 + y1 / 10 % 10)
					n++;
		}
		for (i = y1 + 1; i <= y2 - 1; i++) {
			d[2] = 28 + i % 4 == 0 && i % 100 != 0 || i % 400 == 0;
			for (j = 1; j <= 12; j++) {
				for (k = 1; k <= d[j]; k++)
					if (k == i / 1000 + i / 100 % 10 * 10 && j == i % 10 * 10 + i / 10 % 10)
						n++;
			}
		}
		d[2] = 28 + y2 % 4 == 0 && y2 % 100 != 0 || y2 % 400 == 0;
		for (j = 1; j <= m2 - 1; j++) {
			for (k = 1; k <= d[j]; k++)
				if (k == y2 / 1000 + y2 / 100 % 10 * 10 && j == y2 % 10 * 10 + y2 / 10 % 10)
					n++;
		}
		for (k = 1; k <= d2; k++)
			if (k == y2 / 1000 + y2 / 100 % 10 * 10 && m2 == y2 % 10 * 10 + y2 / 10 % 10)
				n++;
	} else {
		if (m1 != m2) {
			d[2] = 28 + y1 % 4 == 0 && y1 % 100 != 0 || y1 % 400 == 0;
			for (k = d1; k <= d[m1]; k++)
				if (k == y1 / 1000 + y1 / 100 % 10 * 10 && m1 == y1 % 10 * 10 + y1 / 10 % 10)
					n++;
			for (j = m1 + 1; j <= m2 - 1; j++) {
				for (k = 1; k <= d[j]; k++) {
					if (k == y1 / 1000 + y1 / 100 % 10 * 10 && j == y1 % 10 * 10 + y1 / 10 % 10)
						n++;
				}
			}
			for (k = 1; k <= d2; k++)
				if (k == y1 / 1000 + y1 / 100 % 10 * 10 && m2 == y1 % 10 * 10 + y1 / 10 % 10)
					n++;
		} else {
			for (k = d1; k <= d2; k++)
				if (k == y1 / 1000 + y1 / 100 % 10 * 10 && m2 == y1 % 10 * 10 + y1 / 10 % 10)
					n++;
		}
	}
	cout << n;
	return 0;
}
